package com.kim.logs.context;
/**
 * @Deacription TODO
 * @Author jianhua.hong
 * @Date 2020/4/2 18:29
 **/
public final class RequestLogContext {
    private final static ThreadLocal<String> TRACE_ID_THREADLOCAL = new ThreadLocal<>();
    private final static ThreadLocal<String> SPAN_ID_THREADLOCAL = new ThreadLocal<>();
    private final static ThreadLocal<String> PARENT_SPAN_ID_THREADlOCAL = new ThreadLocal<>();
    public static void addTraceId(String id) {
        TRACE_ID_THREADLOCAL.set(id);
    }
    public static String getTraceId() {
        return TRACE_ID_THREADLOCAL.get();
    }
    public static void removeTraceId() {
        TRACE_ID_THREADLOCAL.remove();
    }
    public static void addSpanId(String id) {
        SPAN_ID_THREADLOCAL.set(id);
    }
    public static String getSpanId() {
        return SPAN_ID_THREADLOCAL.get();
    }
    public static void removeSpanId() {
        SPAN_ID_THREADLOCAL.remove();
    }
    public static void addParentSpanId(String id) {
        PARENT_SPAN_ID_THREADlOCAL.set(id);
    }
    public static String getParentSpanId() {
        return PARENT_SPAN_ID_THREADlOCAL.get();
    }
    public static void removeParentSpanId() {
        PARENT_SPAN_ID_THREADlOCAL.remove();
    }
}